<?php

/**
 * 检测验证码
 * @param  integer $id 验证码ID
 * @return boolean     检测结果
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
function check_verify($code, $id = 5){
    $verify = new \Think\Verify();
    return $verify->check($code, $id);
}
function dispatchJump($message,$status=1,$jumpUrl=''){
    if($status) { //发送成功信息
        // 成功操作后默认停留1秒
        $s_message=$message;
        if(!isset($_GET['waitSecond']))    $waitSecond=1;
        // 默认操作成功自动返回操作前页面
        if(empty($jumpUrl)) $jumpUrl=$_SERVER["HTTP_REFERER"];
        include APP_PATH.'Shop/View/Public/dispatch_jump.php';
    }else{
        //发生错误时候默认停留3秒
        $e_message=$message;
        if(!isset($_GET['waitSecond']))    $waitSecond=3;
        // 默认发生错误的话自动返回上页
        if(empty($jumpUrl)) $jumpUrl="javascript:history.back(-1);";
        include APP_PATH.'Shop/View/Public/dispatch_jump.php';
        // 中止执行  避免出错后继续执行
        exit ;
    }
}

function successTip($message,$jumpUrl='') {
    dispatchJump($message,1,$jumpUrl);
}
function errorTip($message,$jumpUrl='') {
    dispatchJump($message,0,$jumpUrl);
}
?>